package cn.stylefeng.guns.sys.modular.system.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.sys.modular.system.entity.BtyMdYydz;
import cn.stylefeng.guns.sys.modular.system.model.params.BtyMdYydzParam;
import cn.stylefeng.guns.sys.modular.system.service.BtyMdYydzService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;


/**
 * 门店营业额报备表控制器
 *
 * @author 
 * @Date 2021-12-03 17:15:17
 */
@Controller
@RequestMapping("/btyMdYydz")
public class BtyMdYydzController extends BaseController {

    private String PREFIX = "/modular/system/btyMdYydz";

    @Autowired
    private BtyMdYydzService btyMdYydzService;

    /**
     * 跳转到主页面
     *
     * @author 
     * @Date 2021-12-03
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/btyMdYydz.html";
    }

    /**
     * 新增页面
     *
     * @author 
     * @Date 2021-12-03
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/btyMdYydz_add.html";
    }

    /**
     * 编辑页面
     *
     * @author 
     * @Date 2021-12-03
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/btyMdYydz_edit.html";
    }

    /**
     * 新增接口
     *
     * @author 
     * @Date 2021-12-03
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(BtyMdYydzParam btyMdYydzParam) {
        this.btyMdYydzService.add(btyMdYydzParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author 
     * @Date 2021-12-03
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(BtyMdYydzParam btyMdYydzParam) {
        this.btyMdYydzService.update(btyMdYydzParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author 
     * @Date 2021-12-03
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(BtyMdYydzParam btyMdYydzParam) {
        this.btyMdYydzService.delete(btyMdYydzParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author 
     * @Date 2021-12-03
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(BtyMdYydzParam btyMdYydzParam) {
        BtyMdYydz detail = this.btyMdYydzService.getById(btyMdYydzParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author 
     * @Date 2021-12-03
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(BtyMdYydzParam btyMdYydzParam, String date) {
        return this.btyMdYydzService.findPageBySpec(btyMdYydzParam, date);
    }


    /**
     * 同步店名
     *
     */
    @ResponseBody
    @RequestMapping("/synList")
    public ResponseData synList() {
        return this.btyMdYydzService.synList();
    }

    /**
     * 获取城市列表
     *
     */
    @ResponseBody
    @RequestMapping("/cityList")
    public ResponseData cityList() {
        return this.btyMdYydzService.cityList();
    }

    /**
     * 导出
     * date 日期
     * id 营业对账id
     * @return
     */
    @ResponseBody
    @RequestMapping("/exportList")
    public void exportList(String date, HttpServletResponse response){
        this.btyMdYydzService.exportList(date, response);
    }

}


